package cn.udinghuo.model.goods.infrastructure;

import com.fasterxml.jackson.annotation.JsonSetter;

import org.springframework.util.Assert;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Column;
import cn.udinghuo.core.domain.entity.BaseAuditTenantAndDeleted;	
import cn.udinghuo.model.goods.infrastructure.RoundType;	
import cn.udinghuo.core.domain.entity.Comment;
import cn.udinghuo.core.domain.entity.ita.CacheKey;

/**
 * @author shizm
 *	计量单位
 */
@Entity
@Table(name="productunit")
public class ProductUnit extends BaseAuditTenantAndDeleted<Long>  {

	private static final long serialVersionUID = -1107296257L;
	/**
	* 计量单位编码code
	*/
	@Comment(value="计量单位编码")
	@Column(name="cCode")
	private String code;
	/**
	* 计量单位名称name
	*/
	@Comment(value="计量单位名称")
	@Column(name="cName")
	private String name;
	/**
	* 数据来源IDoutSysKey
	*/
	@Comment(value="数据来源ID")
	@Column(name="cOutSysKey")
	private String outSysKey;
	/**
	* erp编码erpCode
	*/
	@Comment(value="erp编码")
	@Column(name="cErpCode")
	private String erpCode;
	/**
	* 小数位数unitPrecision
	*/
	@Comment(value="小数位数")
	@Column(name="unitPrecision")
	private Short unitPrecision;
	/**
	* 舍入方式 0:四舍五人，1:入，2:舍unitRoundType
	*/
	@Comment(value="舍入方式 0:四舍五人，1:入，2:舍")
	@Column(name="unitRoundType")
	private Short unitRoundType;
	/**
	* 舍入方式字符串unitRoundTypeStr
	*/
	@Comment(value="舍入方式字符串")
	@Transient
	private String unitRoundTypeStr;
	public String getCode() {
		return this.code;
	}
	
	public void setCode(String value) {
		this.code = value;
	}
	
	public String getName() {
		return this.name;
	}
	
	public void setName(String value) {
		this.name = value;
	}
	
	public String getOutSysKey() {
		return this.outSysKey;
	}
	
	public void setOutSysKey(String value) {
		this.outSysKey = value;
	}
	
	public String getErpCode() {
		return this.erpCode;
	}
	
	public void setErpCode(String value) {
		this.erpCode = value;
	}
	
	public Short getUnitPrecision() {
		return this.unitPrecision;
	}
	
	public void setUnitPrecision(Short value) {
		this.unitPrecision = value;
	}
	
	public RoundType getUnitRoundType() {
        if(this.unitRoundType == null){
			return null;
		}
		return RoundType.find(this.unitRoundType.intValue());
	}
	@JsonSetter
	public void setUnitRoundType(RoundType value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.unitRoundType = value.getValue();
	}
	
	public void setUnitRoundType(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(RoundType.find(value.intValue()),"enum value is invalid value!"); 
		this.unitRoundType = value;
	}
	
	public String getUnitRoundTypeStr() {
		return this.unitRoundTypeStr;
	}
	
	public void setUnitRoundTypeStr(String value) {
		this.unitRoundTypeStr = value;
	}
	
}
